package backup;

import java.io.BufferedReader;
import java.io.FileReader;
import java.util.HashSet;

public class StopWords {

	HashSet<String> stopwords;
	
	public void ReadStopWordFile(String filename){
		
		try{
			if (stopwords == null)
	            stopwords = new HashSet<String>();
	
			FileReader fr = new FileReader(filename);
			BufferedReader reader = new BufferedReader(fr);
			
			String line = "";
	        while ((line = reader.readLine()) != null)
	        {
	            String stopword = line.trim();
	
	            if (!stopword.trim().isEmpty())
	                if (!stopwords.contains(stopword))
	                    stopwords.add(stopword.toUpperCase());
	        }
	        
	        reader.close();
	        fr.close();
		}catch(Exception e){
			e.printStackTrace();
		}
	}
	
	public HashSet<String> GetStopWords(){
		if(stopwords == null)
			stopwords = new HashSet<String>();
		
		return stopwords;
	}
}
